home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 42
/
Amiga Format AFCD42 (Issue 126, Aug 1999).iso
/
-serious-
/
programming
/
other
/
gui4cli
/
docs
/
tutorials
/
gosub.gc
< prev
next >
Wrap
Text File
|
1999-05-14
|
4KB
|
136 lines
G4C
WinBig -1 -1 300 210 "GoSub.gc"
WinType 11110001
usetopaz ; we force the use of topaz font for lining up..
; -------------------------------------------------------------
; This is all the diagram stuff ...
; -------------------------------------------------------------
BOX 0 0 0 0 OUT RIDGE
SQUARE 10 24 40 16 2 NOFILL
SQUARE 20 50 20 10 2 FILL
SQUARE 20 70 20 10 2 FILL
SQUARE 20 90 20 10 2 FILL
SQUARE 10 110 40 16 2 NOFILL
LINE 30 40 30 110 2
LINE 40 55 120 55 2
LINE 40 75 120 75 2
LINE 40 95 120 95 2
LINE 4 134 294 134 1
; -------------------------------------------------------------
; System events
; -------------------------------------------------------------
xonLoad
GuiOpen GoSub.gc
xonClose
GuiQuit GoSub.gc
; -------------------------------------------------------------
; The main contents start here ...
; The texts
; -------------------------------------------------------------
Text 80 2 100 12 'GoSub and xRoutine' 206 NOBOX
Text 80 20 200 10 'Click on the "Gosub"' 20 NOBOX
Text 80 30 200 10 'buttons to see the action.' 26 NOBOX
Text 80 114 200 10 'Then read the script.' 22 NOBOX
Text 20 27 32 12 'In' 2 NOBOX
Text 18 113 32 12 'Out' 3 NOBOX
; -------------------------------------------------------------
; Three buttons to call the subroutines
; In this case, we'll keep the calls themselves simple :
; gosub GuiName RoutineName
; Note however, that Gosub routines, as well as GuiLoad,
; GuiOpen etc can take and return arguments, making them much
; more powerfull than is shown here..
; -------------------------------------------------------------
xButton 120 50 80 12 'Gosub 1'
gosub GoSub.gc SubRoutine1
xButton 120 70 80 12 'Gosub 2'
gosub GoSub.gc SubRoutine2
xButton 120 90 80 12 'Gosub 3'
gosub GoSub.gc SubRoutine3
; -------------------------------------------------------------
; Labels and empty strings for the output
; from the subroutines
; -------------------------------------------------------------
Text 14 140 34 16 ' 1' 2 BOX
gadid 1
Text 14 160 34 16 ' 2' 2 BOX
gadid 2
Text 14 180 34 16 ' 3' 2 BOX
gadid 3
Text 60 142 34 16 ' ' 30 NOBOX
gadid 4
Text 60 162 34 16 ' ' 30 NOBOX
gadid 5
Text 60 172 34 16 ' ' 30 NOBOX
gadid 6
Text 60 182 34 16 ' ' 30 NOBOX
gadid 7
; -------------------------------------------------------------
; Here are the subroutines themselves. All of this is :
; -------------------------------------------------------------
; 1. Very easy to call repeatedly if needed.
; 2. Well clear of the main script (especially useful for
; complex arithmetic or file-handling procedures).
; In fact, these examples are utterly trivial, since all they do is
; update the contents of 7 text gadgets which are already in place.
; The xRoutine names MUST match those called by the 'gosub' commands.
; -------------------------------------------------------------
xRoutine SubRoutine1
Update GoSub.gc 1 ' 1'
Update GoSub.gc 2 ' '
Update GoSub.gc 3 ' '
Update GoSub.gc 4 "Subroutine 1 advises :"
Update GoSub.gc 5 " Subroutines are easy to"
Update GoSub.gc 6 " call when you have any"
Update GoSub.gc 7 " repetitive tasks."
; -------------------------------------------------------------
xRoutine SubRoutine2
Update GoSub.gc 1 ' '
Update GoSub.gc 2 ' 2'
Update GoSub.gc 3 ' '
Update GoSub.gc 4 "Subroutine 2 suggests :"
Update GoSub.gc 5 " Subroutines can help keep"
Update GoSub.gc 6 " your main script clear"
Update GoSub.gc 7 " and easier to read."
; -------------------------------------------------------------
xRoutine SubRoutine3
Update GoSub.gc 1 ' '
Update GoSub.gc 2 ' '
Update GoSub.gc 3 ' 3'
Update GoSub.gc 4 "Subroutine 3 proclaims :"
Update GoSub.gc 5 " Subroutines are an example"
Update GoSub.gc 6 " of modular programming"
Update GoSub.gc 7 " and help you think clearly."